package com.lhl.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.text.SimpleDateFormat;

public class JsonUtils {
    public static String getJson(Object obj) throws JsonProcessingException {
        return getJson(obj,"yyyy-MM-dd");
    }
    public static String getJson(Object obj,String dataFormat) throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setDateFormat(new SimpleDateFormat(dataFormat));
        return objectMapper.writeValueAsString(obj);
    }
}
